package com.egg.ylt.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.egg.ylt.Utils.DateUtils;

import java.util.List;

/**
 * Created by sichaoqi on 2018/10/12.
 */

public class ADA_ViewPagerAdapter extends FragmentPagerAdapter {

    List<Fragment> data;
    List<String> titles;

    public ADA_ViewPagerAdapter(FragmentManager fm, List<Fragment> data, List<String> titles) {
        super(fm);
        this.data = data;
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return this.data.get(position);
    }

    @Override
    public int getCount() {
        return isEmpty() ? 0 : data.size();
    }

    private boolean isEmpty() {
        return data == null || data.size() == 0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        String[] split1 = titles.get(position).split("-");
        return split1[0] + "月" + split1[1] + "日";
    }

}
